using System.Collections.Generic;
using SharpObjects.Configuration;
using SharpObjects.Configuration.ConfigurationProviders;
using SharpObjects.Interfaces;
using SharpObjects.RuleEngine;

namespace SharpRuleEngineTest
{
    public class UiEvent : IXmlInitializable
    {
        public string Name { get; set; }
        public List<IRule> NavigationRules { get; set; }

        public UiEvent()
        {
            this.NavigationRules = new List<IRule>();
        }

        #region IXmlInitializable Members

        public void Initialize(System.Xml.XmlElement initializationElement)
        {
            IConfigurationReader init = new XmlConfigurationProvider(initializationElement);

            this.Name = initializationElement.Name;

            IRule[] rules = init.GetObjects<IRule>("child::*");
            this.NavigationRules.Clear();
            this.NavigationRules.AddRange(rules);

            this.IsInitialized = true;
        }

        public bool IsInitialized { get; set; }

        #endregion
    }
}